import cv2
import time

cap = cv2.VideoCapture('8/1.mp4')

def run_20(cap):
    retval = cap.isOpened()

    while True:
        _, frame = cap.read()
        cv2.imshow('frame', frame)
        
        key = cv2.waitKey(20)           # 每秒50帧

        if key == ord('q'):
            # cap.release()
            cv2.destroyAllWindows()
            break

def run_50(cap):
    retval = cap.isOpened()

    while True:
        _, frame = cap.read()
        cv2.imshow('frame', frame)
        
        key = cv2.waitKey(10)           # 每秒50帧

        if key == ord('q'):
            # cap.release()
            cv2.destroyAllWindows()
            break

def main(cap):
    run_20(cap)
    time.sleep(0.5)
    run_50(cap)
    cap.release()

if __name__ == '__main__':
    main(cap)